﻿<UserControl x:Class="Xinnos.Lca.Yacht.Analyzer.View.ComponentsPanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:this="clr-namespace:Xinnos.Lca.Yacht.Analyzer.View" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.CommandBindings>
        <CommandBinding Command="New" CanExecute="OnCanExecuteNewCommand" Executed="OnExecuteNewCommand" />
        <CommandBinding Command="Delete" CanExecute="OnCanExecuteRemoveCommand" Executed="OnExecuteRemoveCommand" />
    </UserControl.CommandBindings>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="2" />
            <ColumnDefinition Width="3*" />
        </Grid.ColumnDefinitions>
        <ListBox Grid.Column="0" ItemsSource="{Binding Components}" SelectedItem="{Binding Component,UpdateSourceTrigger=PropertyChanged}" >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <TextBox Text="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
                </DataTemplate>
            </ListBox.ItemTemplate>
            <ListBox.ContextMenu>
                <ContextMenu>
                    <MenuItem Command="New" CommandTarget="{Binding Path=PlacementTarget,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ContextMenu}}}" />
                    <MenuItem Command="Delete" CommandTarget="{Binding Path=PlacementTarget,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ContextMenu}}}" />
                </ContextMenu>
            </ListBox.ContextMenu>
        </ListBox>
        <GridSplitter Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="DarkGray" ResizeBehavior="PreviousAndNext" ResizeDirection="Columns" />
        <this:ComponentRatePanel Grid.Column="2" DataContext="{Binding Component}" x:Name="assessmentPanel" />
    </Grid>
</UserControl>